<?php

declare(strict_types=1);

use App\Controller\HomePage\Action as HomePageAction;
use App\Controller\Webhook\CaptureAction;
use App\Controller\Webhook\ClearRequestsAction;
use App\Controller\Webhook\CreateAction;
use App\Controller\Webhook\DeleteAction;
use App\Controller\Webhook\ShowAction;
use App\Controller\Webhook\UpdateResponseAction;
use Yiisoft\Http\Method;
use Yiisoft\Router\Group;
use Yiisoft\Router\Route;

return [
    Group::create()
        ->routes(
            Route::get('/')
                ->action(HomePageAction::class)
                ->name('home'),
            Route::post('/webhooks')
                ->action(CreateAction::class)
                ->name('webhook.create'),
            Route::get('/webhooks/{token}')
                ->action(ShowAction::class)
                ->name('webhook.show'),
            Route::post('/webhooks/{token}/response')
                ->action(UpdateResponseAction::class)
                ->name('webhook.response.update'),
            Route::post('/webhooks/{token}/delete')
                ->action(DeleteAction::class)
                ->name('webhook.delete'),
            Route::post('/webhooks/{token}/requests/clear')
                ->action(ClearRequestsAction::class)
                ->name('webhook.requests.clear'),
        ),
    Group::create()
        ->routes(
            Route::methods(Method::ALL, '/hook/{token}/{suffix:.+}')
                ->action(CaptureAction::class)
                ->name('webhook.capture.with-path'),
            Route::methods(Method::ALL, '/hook/{token}')
                ->action(CaptureAction::class)
                ->name('webhook.capture'),
        ),
];
